<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var isPalindrome = function(head) {
    let p = head
    let arr = []
    while(p){
        arr.push(p.val)
        p = p.next
    }
    if(arr.toString() === arr.reverse().toString()){
        return true
    } else {
        return false
    }
};
    </script>
</body>
</html>